import Vuex from 'vuex'
import Vue from 'vue'

Vue.use(Vuex)
const store = new Vuex.Store({
	strict: process.env.NODE_ENV === 'development',
	state: {
		money: 1000,
		car: '法拉利'
	},
	mutations: {
		add(state) {
			state.money++
		},
		addmore(state, val) {
			state.money += val
		},
		buyli(state, val) {
			state.money -= val
		},
		buyb(state, val) {
			state.money -= val
		},
		doHair(state, val) {
			state.money -= val
		},
	},
	actions: {
		doHairAsync(context, val) {
			setTimeout(() => {
				context.commit('doHair', val)
			}, 1000);
		}
	}
})
export default store